<template>
    <div class="stats-panel">
        <div class="stats-panel-body">
            <div class="stats-btn-group">
                <button type="button" :class="{'stats-checked': chartType == 'Area'}" @click="changeChartType('Area')">{{$t('portal.dataBoard.AreaStatistical')}}</button>
                <button type="button" :class="{'stats-checked': chartType == 'User'}" @click="changeChartType('User')">{{$t('portal.dataBoard.userStatistical')}}</button>
            </div>
            <div class="table_div">
                <el-table
                    v-if="data.length && chartType == 'Area'"
                    :data="data"
                    ref="multipleTable"
                    header-row-class-name="common-list-table-header taks-list-table-header">
                    <el-table-column type="index" :label="$t('portal.dataBoard.sort')"></el-table-column>
                    <el-table-column prop="provinceCity" :label="$t('common.base.region')"></el-table-column>
                    <el-table-column prop="userCount" sortable :label="$t('portal.dataBoard.userQuantity')"></el-table-column>
                    <el-table-column prop="loginCount" sortable :label="$t('portal.dataBoard.loginQuantity')"></el-table-column>
                    <el-table-column prop="eventCount" sortable :label="$t('portal.dataBoard.eventQuantity')"></el-table-column>
                </el-table>
                <el-table
                    v-if="data.length && chartType == 'User'"
                    :data="data"
                    ref="multipleTable"
                    header-row-class-name="common-list-table-header taks-list-table-header">
                    <el-table-column type="index" :label="$t('portal.dataBoard.sort')"></el-table-column>
                    <el-table-column prop="userName" :label="$t('portal.dataBoard.user')"></el-table-column>
                    <el-table-column prop="loginCount" sortable :label="$t('portal.dataBoard.loginQuantity')"></el-table-column>
                    <el-table-column prop="eventCount" sortable :label="$t('portal.dataBoard.eventQuantity')"></el-table-column>
                </el-table>
                <BaseListForNoData v-if="!data.length" :notice-msg="$t('common.base.tip.noData')"></BaseListForNoData>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    props: {
        data: {
            type: Array,
            default: () => []
        },
    },
    data() {
        return {
            chartType: 'Area',
        }
    },
    watch: {
        list: function(newValue, oldValue){
            if (newValue) {
                this.updateCharts(newValue);
            }
        },
    },
    methods: {
        changeChartType(type) {
            this.chartType = type
            this.$emit('change', type)
        },
    },
    mounted() {
    },
    beforeDestroy() {
    },
};
</script>

<style lang="scss" scoped>
.stats-panel{
    margin-top: 0;
}
.stats-btn-group{
    margin-left: 16px;
    padding-top: 0;
}
.table_div{
    padding: 0 16px;
    height: 450px;
    overflow: auto;
}
</style>
